﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._08_桥接模式
{
    /// <summary>
    /// DHL国际物流
    /// </summary>
    public class DHLlogistics : ILogisticsCompany
    {
        /// <summary>
        /// 计算费用
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="volume"></param>
        /// <returns></returns>
        public decimal CalculateFreight(decimal weight, decimal volume)
        {
            Console.WriteLine("计算运单费用》。。");
            return (weight * 15) + (volume * 200);
        }

        /// <summary>
        /// 取消运单
        /// </summary>
        /// <param name="waybillNumber"></param>
        public void CancelShipment(string waybillNumber)
        {
            Console.WriteLine($"DHL取消国际运单：{waybillNumber}（需支付取消费用）");
        }

        /// <summary>
        /// 创建运单
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public string CreateWaybill()
        {
            string waybill = $"DHL{DateTime.Now:yyyyMMddHHmmss}";
            Console.WriteLine($"DHL创建国际运单：{waybill}");
            return waybill;
        }

        /// <summary>
        /// 获取公司名称
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public string GetCompanyName() => "DHL国际快递";

        /// <summary>
        /// 获取物流状态
        /// </summary>
        /// <param name="waybillNumber"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public string TrackShipment(string waybillNumber)
        {
            return new Random().Next(100) > 20 ? "已到达德国法兰克福枢纽" : "国际运输中";
        }
    }
}
